<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core" lang="pt-br">

<f:view>
	<ui:composition template="/template/templatePadrao.xhtml">
		<ui:define name="body">
		
			<h:form id="form_funcao">	
				<p:growl id="growl" /> 
				<h:outputText value="Função" styleClass="breadcrumb"/><br /><br />
				<h:panelGroup id="panel_funcao">
					<p:panel header="Cadastro">
						<h:panelGrid columns="2">
							<h:outputText value="Função" />
							<h:inputText value="#{funcaoManager.funcao.funcao}" required="true" label="Função"/>
							
							<h:outputText value="Descrição" />
							<h:inputText value="#{funcaoManager.funcao.descricao}" required="true" label="Descrição"/>
						</h:panelGrid>
						<p:commandButton action="#{funcaoManager.save}" value="Salvar" rendered="#{funcaoManager.funcao.id == null}" update="form_funcao,growl"/>
						<p:commandButton action="#{funcaoManager.update}" value="Salvar" rendered="#{funcaoManager.funcao.id != null}" update="form_funcao,growl"/>
						
					</p:panel>
				</h:panelGroup>

				<h:panelGroup id="panel_table">
					<p:dataTable value="#{funcaoManager.listFuncao}" var="es" rows="5" paginator="true"
					emptyMessage="Não existem resultados."
					>
						<p:column headerText="Função">
							<h:outputText value="#{es.funcao}" />
						</p:column>
						
						<p:column headerText="Descrição">
							<h:outputText value="#{es.descricao}" />
						</p:column>
						<p:column headerText="Ação">
							<p:commandButton action="#{funcaoManager.prepareUpdate}" value="Atualizar" process="@this" update=":form_funcao:panel_funcao,:form_funcao:growl">
								<f:setPropertyActionListener target="#{funcaoManager.funcao}" value="#{es}" />
							</p:commandButton>
							<p:commandButton action="#{funcaoManager.delete}" value="Excluir" process="@this" update=":form_funcao:panel_table,:form_funcao:growl">
								<f:setPropertyActionListener target="#{funcaoManager.funcao}" value="#{es}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</h:panelGroup>
			
			</h:form>
		
		</ui:define>
	</ui:composition>
</f:view>
</html>